<?php
/*
 * 获取分页所需要的参数
 * @param $page
 * @param $pagesize
 * @param $count
 * 
 * return array
 *   */
    function getPageArr($page,$pagesize=10,$count) {
    $page           = isset($page)?abs(intval($page)):1;
    $pagesize       = isset($pagesize)?abs(intval($pagesize)):10;
    $page > 100000 && $page = 100000;
    $pagesize > 100 && $page = 100;
    $pagetotal      = ceil($count / $pagesize);
    ($page>$pagetotal) && ($page = $pagetotal);
    ($page<1) && ($page = 1);
    
    //下一页
    if($page>$pagetotal){
      $nextpage=$pagetotal;
    }else{
        $nextpage=$page+1;
    }
    //上一页
    if($page>1){
      $prevpage=$page-1;
    }else{
      $prevpage=$page;
    }

    $pagearr = array(
        "page"      =>$page,
        "pagesize"  =>$pagesize,
        "pagetotal"=>$pagetotal,
        "count" =>$count,
        "start"=>($page - 1) * $pagesize,
        "nextpage"=>$nextpage,
        "prevpage"=>$prevpage

    );
    return $pagearr;
    }

